package com.woniuxy.controller;

import com.woniuxy.entity.RbacMenu;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/rbacMenu")
public class RbacMenuController {
    @Autowired
    RbacMenuService rbacMenuService;
    @GetMapping("/")
    public ResponseEntity findAllMenu(){
        return rbacMenuService.findAllMenu();
    }
    @PutMapping("/")
    public ResponseEntity editOne(@RequestBody RbacMenu rbacMenu){
        return rbacMenuService.editOne(rbacMenu);
    }
    @PutMapping("/{id}/{fid}")
    public ResponseEntity updateMenu(@PathVariable int id,@PathVariable Integer fid){
        return rbacMenuService.updateMenu(id,fid);
    }
    @GetMapping("/findMenuById/{id}")
    public ResponseEntity findMenuById(@PathVariable("id") int id) {
        return rbacMenuService.findMenuById(id);
    }

    @RequestMapping("/findMenuIdsByRoleId/{rid}")
    public ResponseEntity findMenuIdsByRoleId(@PathVariable("rid") int rid) {
        return rbacMenuService.findMenuIdsByRoleId(rid);
    }

    @GetMapping("/getIds/{id}")
    public ResponseEntity getRoleMenuIds(@PathVariable int id){
        return rbacMenuService.getRoleMenuIds(id);
    }

    @PostMapping("/{rid}/{ids}")
    public ResponseEntity addRoleMenu(@PathVariable int[] ids,@PathVariable int rid){
        return rbacMenuService.addRoleMenu(rid,ids);
    }

    @PostMapping("/del/{rid}/{ids}")
    public ResponseEntity deleteRoleMenu(@PathVariable int[] ids,@PathVariable int rid){
        return rbacMenuService.deleteRoleMenu(rid,ids);
    }

}
